#ifndef PARTICLESOURCE1D_EMIT_H
#define PARTICLESOURCE1D_EMIT_H

#include <vector>
#include "ParticleSource1D.h"


using namespace std;

class ParticleSource1D_Emit : public ParticleSource1D
{

public:

    ParticleSource1D_Emit(PicParams* params_, ParallelMPI* pmpi_, PhysicalField* fields_, vector<Species*>* vecSpecies_, ParticleSourceParameter ps_param_);

    ~ParticleSource1D_Emit();


    //Method called in the main pic loop to apply collision at each timestep
    void emitLoad(int itime);


    //particle number emitted every timestep
    int number_particle_emit;

    //PSI position : only left and right for 1D case
    string emitPos;

    //the energy/temperature of the new particles
    double emitTemp;

    //Emitted particle flux from boundary
    double emitFlux;

    //emitting tempreature
    double emitOffset;

    //The particle number emitted from boundary at one time (emit_step), not one timestep(!!!)
    int emit_step;

    //emit_rem = emit_step * emitDn *... - emitNumber
    double emit_rem;
    double emit_rem_tot;

private:
    double dt_ov_dx;
    double dt;
    double YZArea;
    //electric field used for field emit, equal to electric field on the boundary
    double emitField;
    //Emitted current density from boundary
    double emitJ;

    //nominalDensity and nomPtclsPerCell is used to set the weight_const
    //weight_cosnt = nominalDensity * CellVolume / nomPtclsPerCell
    double nominalDensity;
    double nomPtclsPerCell;


    //some parameters for field emission
    //from "modelling vacuum arcs: from plasma initiation to surface interactions"
    double a_FN;
    double b_FN;
    double work_function;
    double ySqrt_factor;
    double a_factor;
    double b_factor;

    double t_y2(double Eloc) { return 1.0; };
    double v_y(double Eloc)
    {
        return 0.956 - 1.062*ySqrt_factor*Eloc;
    }

    //paramets for relEmit
    double relEmit_factor;



};


#endif
